<?php

class Application_Model_DbTable_Administradores extends Zend_Db_Table_Abstract
{

    protected $_name = 'administradores';
	
	public function getAdministradores() {
		$select  = $this->_db->select()
			->from($this->_name);
		// print_r($select->__toString());die();

		$result = $this->getAdapter()->fetchAll($select);

		return $result;
	}
	
	// getAdminFromId
	public function getAdminFromId($idAdmin) {
		$select  = $this->_db->select()
			->from($this->_name)->where('id_admin = ?', $idAdmin);
		//print_r($select->__toString());die();
		$result = $this->getAdapter()->fetchAll($select);

		return $result;
	}
	
	public function getDatosClienteFromUser($user) {
		$select  = $this->_db->select()
			->from($this->_name)->where('usuario = ?', $user);
		//print_r($select->__toString());die();
		$result = $this->getAdapter()->fetchAll($select);

		return $result;
	}
	
	public function setLastLogin($user) {
		$data = array('ultimo_ingreso'=>date('Y-m-d H:i:s'));
		$where = $this->getAdapter()->quoteInto('usuario = ?', $user);
		$result = $this->update($data, $where);

		return $result;
	}
}

